package com.application.fragment;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.application.BR;
import com.application.R;
import com.application.base.BaseFragment;
import com.application.databinding.FragmentFirstHomeBinding;
import com.application.viewmodel.FirstViewModel;

public class FirstHomeFragment extends BaseFragment<FragmentFirstHomeBinding, FirstViewModel> {

    public FirstHomeFragment() {
    }

    public static FirstHomeFragment newInstance() {
        return new FirstHomeFragment();
    }

    @Override
    protected int initLayoutId() {
        return R.layout.fragment_first_home;
    }

    @Override
    protected int initVariableId() {
        return BR.homeViewModel;
    }

    @Override
    protected FirstViewModel initViewModel() {
        if (getParentFragment() instanceof FirstFragment) {
            FirstFragment parentFragment = (FirstFragment) getParentFragment();
            return parentFragment.viewModel;
        }
        return null;
    }

    @Override
    protected void initData() {
        super.initData();
        binding.setFragment(this);
        if (viewModel != null) {
            String homeData = viewModel.getTabTitles().getValue().get(0);
            binding.setHomeData(homeData);
        }
    }
}